package com.project.logistics.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.logistics.bean.Repairs;
import com.project.logistics.controller.RepairmanController;
import com.project.logistics.mapper.RepairsMapper;
import com.project.logistics.service.RepairsService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by94988 on 2021/3/19 16:50
 */
@Service
public class RepairsServiceImpl extends ServiceImpl<RepairsMapper,Repairs> implements RepairsService{

    @Autowired
    RepairsMapper repairsMapper;

    @Override
    public List<Repairs> getUndealrepairs() {
        List<Repairs> undealrepairs = repairsMapper.getUndealrepairs();
        for (Repairs undealrepair : undealrepairs) {
            switch (undealrepair.getRepairsStatus()){
                case 1:
                    undealrepair.setStatus("未受理");
                    break;
                case 2:
                    undealrepair.setStatus("已派工");
                    break;
                case 3:
                    undealrepair.setStatus("已完成");
            }

        }
        return undealrepairs;
    }

    @Override
    public int setRepairman(String serviceUserId, int repairsId) {
        return repairsMapper.setRepairman(serviceUserId,repairsId);
    }

    @Override
    public Repairs getRepairById(int id) {
        return repairsMapper.getRepairById(id);
    }

    @Override
    public int deleteRepairs(int repairsId) {
        return repairsMapper.deleteRepairs(repairsId);
    }

//    @Override
//    public List<Repairs> getRepairsCount(String id) {
//        return repairsMapper.getRepairsCount(id);
//    }


    @Override
    public List<Repairs> getRepairsByUserId(String userId)
    {
        return repairsMapper.getRepairsByUserId(userId);
    }

    @Override
    public List<Repairs> getRepairsByRepairsmanId(String repairsmanId){
        return repairsMapper.getRepairsByRepairsmanId(repairsmanId);
    }

    @Override
    public List<Repairs> getAllRepairs(){
        return repairsMapper.getAllRepairs();
    }

    @Override
    public Repairs getRepair(int repairsId){
        return repairsMapper.getRepair(repairsId);
    }

    @Override
    public void insertRepairs(Repairs repairs){
        repairsMapper.insertRepairs(repairs);
    }

    @Override
    public void updateRepairs(Repairs repairs){
        repairsMapper.updateRepairs(repairs);
    }

    @Override
    public void updateRepairsStatus(int repairsStatus,int repairsId){
        repairsMapper.updateRepairsStatus(repairsStatus,repairsId);
    }

    @Override
    public List<Repairs> getAllUnRepairs() {
        return repairsMapper.getAllUnRepairs();
    }

    @Override
    public List<Repairs> getAllDealRepairs() {
        return repairsMapper.getAllDealRepairs();
    }

    @Override
    public List<Repairs> getRepairsByRepairsmanIdAndStatus(String repairsmanId,int repairsStatus){
        Logger logger=Logger.getLogger(RepairmanController.class);
        logger.info("进入service");
        return repairsMapper.getRepairsByRepairsmanIdAndStatus(repairsmanId,repairsStatus);
    }


}
